var vm = new Vue({
	el : '#rrapp',
	data : {
		dataContract : {},
		dataContractpayList:[]
	},
	created: function() {
		var id = GetRequest(location.search)["id"];
		$.get("../datacontract/infoXtd/"+id+"?_" + $.now(), function(r){
            vm.dataContract = r.dataContract;
           if(vm.dataContract.contractdate !=null){
            	vm.dataContract.contractdate = vm.dataContract.contractdate.substring(0,10);
            }
            vm.dataContractpayList=r.dataContractpayList;
			initGrid(vm.dataContractpayList);
			//console.log(vm.hbApptransHead)
			//console.log(vm.hbApptransBody)
        });
	}
});

function initGrid(data) {
	$("#jqGrid").jqGrid({
		datatype : 'local',
		data: data || [],
		colModel : [ {
			label: 'id',
			name : "id",
			index : "id",
			key : true,
			hidden: true
		}, {
			label: 'hisid',
			name : "hisid",
			index : "hisid",
			align : 'center',
			hidden : true
		}, {
			label: 'contractid',
			name : "contractid",
			index : "contractid",
			align : 'center',
			hidden : true
		}, {
			label: '收款时间',
			name : "paytime",
			index : "paytime",
			width : '100',formatter: function(value, options, row){
				return value === null ? 
						'' : 
							value.substring(0,7);
				} 
		}, {
			label: '剩下应收',
			name : "shouldmoney",
			index : "shouldmoney",
			align : 'center',
			width : '100'
		}, {
			label: '当月实收',
			name : "paidmoney",
			index : "paidmoney",
			align : 'center',
			width : '100'
		}],
		rowNum: data.length,
		multiselect : false,
		ondblClickRow:function(row){  
            var rowData = $('#jqGrid').jqGrid('getRowData',row);  
            if(rowData.hisid==null || rowData.hisid.length==0){
            	look(rowData.id);
            }else{
            	look(rowData.hisid);
            	}
              
        },
		gridComplete : function() {
			// 隐藏grid底部滚动条
			$(this).closest(".ui-jqgrid-bdiv").css({
				"overflow-x" : "hidden"
			});
			$(this).jqGrid("setGridWidth", vm.$el.offsetWidth * 1, true);
			$(this).jqGrid("setLabel", 'rn', '序号', {'text-align': 'center'});
		},
		rownumbers: true,
		rownumWidth: 40,
	});
}
function look(id) {
	top.layer.open({
		type : 2,
		title : '当月分成人员详情',
		area : [ '80%', '90%' ],
		shadeClose : false,
		content : 'zjdc/datacontractpaydetailXtd.html?id=' +id,
		btn : [ '确认', '取消' ],
		yes : function(index, layero) {
			top.layer.close(index);
		}
	});
}